package cn.lzh.quartzadmin.api;

import cn.lzh.quartzadmin.biz.ISysJobLogService;
import cn.lzh.quartzadmin.cfg.AjaxResult;
import cn.lzh.quartzadmin.po.SysJobLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 定时任务-执行日志
 */
@RestController
@RequestMapping("/monitor/jobLog")
public class SysJobLogController {


    @Autowired
    private ISysJobLogService jobLogService;



    @GetMapping("/list")
    public AjaxResult list(SysJobLog jobLog) {
        List<SysJobLog> list = jobLogService.selectJobLogList(jobLog);
        return AjaxResult.success(list);
    }

    @GetMapping("/remove")
    public AjaxResult remove(String ids) {
        int rows = jobLogService.deleteJobLogByIds(ids);
        return rows > 0 ? AjaxResult.success() : AjaxResult.error();
    }

    @GetMapping("/detail/{jobLogId}")
    public AjaxResult detail(@PathVariable("jobLogId") Long jobLogId) {
        return AjaxResult.success(jobLogService.selectJobLogById(jobLogId));
    }

    @GetMapping("/clean")
    public AjaxResult clean() {
        jobLogService.cleanJobLog();
        return AjaxResult.success();
    }

}
